import request from '@/utils/request';

// 查询定时任务详细
export function queryById(id) {
  return request({
    url: '/monitor/job/queryById/' + id,
    method: 'get',
  });
}

// 分页查询定时任务列表
export function pageList(query) {
  return request({
    url: '/monitor/job/pageList',
    method: 'get',
    params: query,
  });
}

// 分页查询逻辑删除的定时任务列表
export function pageRecycle(params) {
  return request({
    url: '/monitor/job/pageRecycle',
    method: 'get',
    params,
  });
}

// 分页查询已发布的定时任务列表
export function pageRelease(params) {
  return request({
    url: '/monitor/job/pageRelease',
    method: 'get',
    params,
  });
}

// 查询定时任务列表
export function queryList(query) {
  return request({
    url: '/monitor/job/queryList',
    method: 'get',
    params: query,
  });
}

// 分页查询逻辑删除的定时任务列表
export function queryRecycle(params) {
  return request({
    url: '/monitor/job/queryRecycle',
    method: 'get',
    params,
  });
}

// 查询已发布的定时任务列表
export function queryRelease(params) {
  return request({
    url: '/monitor/job/queryRelease',
    method: 'get',
    params,
  });
}

// 新增定时任务
export function insert(data) {
  return request({
    url: '/monitor/job/insert',
    method: 'post',
    data: data,
  });
}

// 修改定时任务
export function updateById(data) {
  return request({
    url: '/monitor/job/updateById',
    method: 'put',
    data: data,
  });
}

// 根据id批量审核
export function auditByIds(ids) {
  return request({
    url: '/monitor/job/auditByIds/' + ids,
    method: 'put',
  });
}

// 根据id批量反审核
export function unauditByIds(ids) {
  return request({
    url: '/monitor/job/unauditByIds/' + ids,
    method: 'put',
  });
}
// 导出当前查询列表
export function exports(params) {
  return request({
    url: '/monitor/job/export',
    method: 'post',
    params,
  });
}

// 删除定时任务
export function deleteByIds(ids) {
  return request({
    url: '/monitor/job/deleteByIds/' + ids,
    method: 'delete',
  });
}

// 根据id批量还原删除的定时任务
export function recoverByIds(ids) {
  return request({
    url: '/monitor/job/recoverByIds/' + ids,
    method: 'put',
  });
}
// 根据id批量逻辑删除定时任务
export function removeByIds(ids) {
  return request({
    url: '/monitor/job/removeByIds/' + ids,
    method: 'delete',
  });
}

// 任务状态修改
export function changeJobStatus(id, switchState) {
  const data = {
    id,
    switchState,
  };
  return request({
    url: '/monitor/job/changeStatus',
    method: 'put',
    data: data,
  });
}

// 定时任务立即执行一次
export function runJob(id, jobGroup) {
  const data = {
    id,
    jobGroup,
  };
  return request({
    url: '/monitor/job/run',
    method: 'put',
    data: data,
  });
}
